let nameMsg = document.querySelector('.nameBox>input');
let phoneMsg = document.querySelector('.phoneBox>input');
let cardMsg = document.querySelector('.cardBox>input');

let myAppoint = document.querySelector('.myAppoint');
let startAppoint = document.querySelector('.startAppoint');
// console.log(startAppoin);

//我的预约
startAppoint.addEventListener('click', () => {
    // console.log(nameMsg);
    let name = nameMsg.value;
    let phone = phoneMsg.value;
    let card = cardMsg.value;


    //设置ajax
    let url = 'http://newshopapi.0melon0.cn/api/f_user/register';
    let data = {
        'name': name,
        "phone": phone,
        "card": card
    };

    //请求数据
    ajax(url, data, "POST").then(res => {
        console.log(res.result.token);
        sessionStorage.setItem("token", res.result.token)
        sessionStorage.setItem("name", name);
        sessionStorage.setItem("phone", phone);
        sessionStorage.setItem("card", card);
        location.href = "2book.html"
    }).catch(err => {
        console.log(err);
    })

})

//我的预约
myAppoint.addEventListener('click', () => {
    // console.log(nameMsg);
    let name = nameMsg.value;
    let phone = phoneMsg.value;
    let card = cardMsg.value;


    //设置ajax
    let url = 'http://newshopapi.0melon0.cn/api/f_user/register';
    let data = {
        'name': name,
        "phone": phone,
        "card": card
    };

    //请求数据
    ajax(url, data, "POST").then(res => {
        console.log(res);
        console.log(res.result.token);
        sessionStorage.setItem("token", res.result.token)
        sessionStorage.setItem("name", name);
        sessionStorage.setItem("phone", phone);
        sessionStorage.setItem("card", card);
        location.href = "4mybook.html"
    }).catch(err => {
        console.log(err);
    })

})